<template>
	<Modal class-name="update-modal" v-model="visible" :closable="true" :mask-closable="false" footer-hide @on-cancel="clickHandle">
		<div slot="header" class="modal-header"></div>
		<div class="update-box">
			<Logo width="5.25rem" height="4.38rem"></Logo>

			<div class="content">
				<p class="title">发现新版本：{{ data.version }}</p>
				<div class="desc">
					<p class="desc-title">更新详情：</p>
					<div v-html="list"></div>
				</div>
				<div class="action">
					<Button type="primary" @click="clickUpdate">立即升级</Button>
				</div>
			</div>
		</div>
	</Modal>
</template>
<script>
import Logo from '@/components/svg/logo.vue'
export default {
	components: {
		Logo
	},
	props: {
		value: {
			type: Boolean,
			default: false
		},
		data: {
			type: Object,
			default: () => {}
		}
	},
	watch: {
		value(val) {
			this.visible = val
		}
	},
	computed: {
		visible: {
			get() {
				return this.value
			},
			set(val) {
				this.$emit('input', val)
			}
		},
		list() {
			let strs = []
			if (this.data.remark && this.data.remark !== '') {
				this.data.remark
					.replace(/<br\/>/g, '#')
					.split('#')
					.forEach((item) => {
						strs.push(`<p class='desc-content' style='margin-bottom: 0.5rem;'>${item}</p>`)
					})
			}

			return strs.join('')
		}
	},
	data() {
		return {}
	},
	methods: {
		clickHandle() {
			this.visible = false
		},
		clickUpdate() {
			this.visible = false
			// this.$emit('update')
			chrome.webview.hostObjects.form.OnPageEvent('updatenow')
		}
	}
}
</script>
<style lang="less" scoped>
/deep/.ivu-modal {
	width: 36.06rem;
	top: 3.5rem;
}
/deep/.ivu-modal-header {
	border: 0 !important;
	padding: 0.2rem;
	height: 2.34rem;
}
/deep/.ivu-modal-close .ivu-icon-ios-close {
	color: var(--header-close-color);
}
/deep/.ivu-modal-body {
	padding: 32px;
	padding-top: 0;
}
/deep/.ivu-modal-content {
	border-radius: 1rem;
}
.update-modal {
	.update-box {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		/deep/.fill-color {
			fill: var(--bg-color);
		}
		/deep/.fill-color2 {
			fill: var(--svg-logo-color);
		}
		.content {
			display: flex;
			flex-direction: column;
			// margin-left: 32px;
			.title {
				font-family: PingFangSC-Semibold;
				font-size: 1.25rem;
				color: var(--setting-text-title-color);
				letter-spacing: 0;
				font-weight: 600;
				margin-top: 0.99rem;
				margin-bottom: 1.48rem;
			}
			.desc {
				font-family: PingFangSC-Regular;
				font-size: 1.13rem;
				color: var(--setting-text-color);
				letter-spacing: 0;
				font-weight: 400;
				.desc-title {
					margin-bottom: 0.5rem;
				}
			}
			.desc-content {
				font-family: PingFangSC-Regular;
				font-size: 1.13rem;
				color: var(--setting-text-color);
				letter-spacing: 0;
				font-weight: 400;
			}
			.action {
				margin-top: 1.4rem;
			}
			.action button {
				border-radius: 1.8rem;
				padding: 0.5rem 2.05rem 0.5rem 2.05rem;
				height: 3rem;
				font-weight: 600;
			}
			.action /deep/.ivu-btn-default span {
				font-family: PingFangSC-Semibold;
				font-size: 1.13rem;
				line-height: 2rem;
				color: #ffffff;
				letter-spacing: 0;
				// line-height: 32px;
				font-weight: 600;
			}
		}
	}
}
</style>
